$(function (){
    //页面初始显示
    disTable("page/start");
})
//翻页显示
function disTable(url){
    $.ajax({
        url:url,
        type:"get",
        dataType:"json",
        success:function (data) {
            if (data!=null) {
                mySuccess(data);
            }
        }
    });
}
//删除记录
function del(url,id) {
    if(confirm("确定删除?")) {
        $.ajax({
            url: url,
            type: "get",
            dataType: "json",
            success:function (){
                $(id).remove();
            }
        });
    }
}
// function getJobTime() {
//     let date=new Date();
//     return "本次工作信息收录时间为"+date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
// }
function mySuccess(data) {
    $("#jobTable").empty();
    //加上更新本次招聘信息的时间
    // $("#recordTime").empty().append(getJobTime());
    $(data).each(function (index,job){
        $("#jobTable").
        append("<tr id='"+job.id+"'>"+
                    "<td>"+job.id+"</td>"+
                    "<td>"+job.jobName+"</td>"+
                    "<td>"+job.pushTime+"</td>"+
                    "<td>"+job.salary+"</td>"+
                    "<td>"+job.place+"</td>"+
                    "<td>"+job.good+"</td>"+
                    "<td>"+job.companyName+"</td>"+
                    "<td>"+job.origin+"</td>"+
                    "<td>"+
                        "<a style='color: white' class='btn btn-sm btn-danger'\n"+
                            "onclick='del(\"delcur/"+job.id+"\",\"#"+job.id+"\")'>删除" +
                        "</a>"+<!--小，红色,根据id删除-->
                    "</td>"+
            "</tr>");
    })
}